from PyQt5.QtCore import QObject
from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import QApplication, QWidget

class ThemeColor(QObject):
    _baseColor = QColor(0x50, 0x50, 0x50)  # 默认颜色 #505050

    def __init__(self, parent=None):
        super().__init__(parent)

    @classmethod
    def setBaseColor(cls, color: QColor):
        if not color.isValid():
            return
        cls._baseColor = color
        # 更新所有顶层窗口
        for widget in QApplication.topLevelWidgets():
            if isinstance(widget, QWidget):
                widget.update()

    @classmethod
    def baseColor(cls) -> QColor:
        return cls._baseColor